package cn.keniykey.mc.viewlibrary.channel;

import org.bukkit.entity.Player;

import cn.keniykey.mc.viewlibrary.ViewLibraryMain;
import cn.keniykey.mc.viewlibrary.reflection.ReflectionUtil;
import cn.keniykey.mc.viewlibrary.toolkit.VerAnalysisUtil;

public abstract class AbChannelUtil {
	protected AbChannelUtil() {}
	
	private static AbChannelUtil util;
	static final String CHANNEL_MAIN = "packet_handler";
	static final String CHANNEL_NAME = "viewlibrary_packet_handler";
	
	static {
		if(ReflectionUtil.isForgeServer()) {
			util = new ChannelUtilForgeV1_12_1();
		}else {
			if(VerAnalysisUtil.isAfter("1.17")) {
				util = new ChannelUtilV1_17_1();
			}else {
				util = new ChannelUtilV1_16_3();
			}
		}
		ViewLibraryMain.getPlugin().getLogger().info("AbChannelUtil调用: " + util.getClass().getSimpleName());
	}
	
	public static AbChannelUtil getUtil() {
		return util;
	}
	
	public abstract void addPlayerAbPacketReceiveHandler(Player player,AbPacketReceiveHandler handler);
	public abstract void removePlayerAbPacketReceiveHandler(Player player);
	public abstract void sendPacket(Player player, Object packet);
}